/**
 * 封装枚举
 */

const enums = {
  namespaced: true,
  state: {
    // 审核状态
    WfShStatus: [
      {value: '1', label: '待审核'},
      {value: '2', label: '审核通过'},
      {value: '3', label: '审核不通过'},
      {value: '4', label: '直接上报'}
    ],
    // 上传状态
    WfDataStatus: [
      {value: '1', label: '待上传'},
      {value: '2', label: '上传成功'},
      {value: '3', label: '上传失败'},
      {value: '4', label: '已过期'}
    ],

    // 车辆状态
    carStatus: [
      {value: '0', label: '空闲'},
      {value: '1', label: '忙碌'},
      {
        value: '2',
        label: '报警',
        children: [
          {value: '0', label: '其它各种报警'},
          {value: '1', label: '超速'},
          {value: '2', label: '围栏报警'}
        ]
      },
      {
        value: '3',
        label: '异常',
        children: [
          {value: '0', label: '其它各种异常'},
          {value: '1', label: 'SOS异常'},
          {value: '2', label: '缺水'},
          {value: '3', label: '缺泡沫'},
          {value: '4', label: '车辆故障'}
        ]
      },
      {value: '4', label: '离线'}
    ],
    // 号牌种类
    hpzl: [
      {value: '02', label: '小型汽车'},
      {value: '01', label: '大型汽车'},
      {value: '08', label: '轻便摩托车'},
      {value: '07', label: '两轮或三轮摩托车'},
      {value: '13', label: '农用运输车'},
      {value: '06', label: '外籍汽车'},
      {value: '04', label: '领馆汽车'},
      {value: '03', label: '使馆汽车'},
      {value: '09', label: '使馆摩托车'},
      {value: '10', label: '领馆摩托车'},
      {value: '11', label: '境外摩托车'},
      {value: '12', label: '外籍摩托车'},
      {value: '05', label: '港澳入出境车'},
      {value: '14', label: '拖拉机'},
      {value: '15', label: '挂车'},
      {value: '16', label: '教练汽车'},
      {value: '23', label: '警用汽车'},
      {value: '17', label: '教练摩托车'},
      {value: '18', label: '试验汽车'},
      {value: '19', label: '试验摩托车'},
      {value: '20', label: '临时入境汽车'},
      {value: '21', label: '临时入境摩托车'},
      {value: '22', label: '临时行驶车'},
      {value: '24', label: '警用摩托车'},
      {value: '26', label: '香港车'},
      {value: '27', label: '澳门车'},
      {value: '51', label: '大型新能源汽车'},
      {value: '52', label: '小型新能源汽车'}
    ],
    // 车牌类型
    colour: [
      {value: '蓝牌', label: '蓝牌'},
      {value: '黄牌', label: '黄牌'},
      {value: '黑牌', label: '黑牌'}
    ],
    // 车牌类型
    record_type: [
      {value: '1', label: '后台'},
      {value: '2', label: '车机'},
      {value: '3', label: '警情'}
    ],
    // 缉查机构
    surveillancetype: [
      {value: 'A', label: '正常'},
      {value: 'B', label: '转出'},
      {value: 'C', label: '被盗抢'},
      {value: 'D', label: '停驶'},
      {value: 'E', label: '注销'},
      {value: 'G', label: '违法未处理'},
      {value: 'H', label: '海关监管'},
      {value: 'I', label: '事故未处理'},
      {value: 'J', label: '嫌疑车'},
      {value: 'K', label: '查封'},
      {value: 'L', label: '扣留'},
      {value: 'M', label: '达到报废标准'},
      {value: 'N', label: '事故逃逸'},
      {value: 'O', label: '锁定'},
      {value: 'P', label: '达到报废标准公告牌证作废'},
      {value: 'Q', label: '逾期未检验'}
    ],
    // 行为类型
    behavior: [
      {value: '0', label: '摄像头不规范'},
      {value: '1', label: '车内仪态'},
      {value: '2', label: '未穿戴反光背心'},
      {value: '3', label: '未按时巡逻'},
      {value: '4', label: '驶离巡控路线'}
    ],
    // 车辆使用用途
    propSuperior: [
      {
        value: '警用车',
        label: '警用车',
        children: [
          {value: '警用摩托', label: '警用摩托'},
          {value: '警用汽车', label: '警用汽车'},
          {value: '特警用车', label: '特警用车'},
          {value: '汉警快骑', label: '汉警快骑'},
          {value: '武装处突车', label: '武装处突车'},
          {value: '市局巡逻车', label: '市局巡逻车'},
          {value: '分局巡逻车', label: '分局巡逻车'}
        ]
      },
      {
        value: '消防车',
        label: '消防车',
        children: [
          {value: '指挥车', label: '指挥车'},
          {value: '抢险救援车', label: '抢险救援车'},
          {value: '水罐车', label: '水罐车'},
          {value: '水罐泡沫车', label: '水罐泡沫车'},
          {value: '高喷车', label: '高喷车'},
          {value: '云梯车', label: '云梯车'},
          {value: '充气车', label: '充气车'}
        ]
      },
      {value: '出租营运', label: '出租营运'},
      {value: '客运', label: '客运'},
      {value: '工程运输', label: '工程运输'},
      {value: '危险品运输', label: '危险品运输'},
      {value: '搬家公司车', label: '搬家公司车'},
      {value: '混凝土搅拌车', label: '混凝土搅拌车'},
      {value: '绿通车', label: '绿通车'},
      {value: '普通货运车', label: '普通货运车'},
      {value: '邮政快递车', label: '邮政快递车'}
    ],
    // 警情级别
    jqjb: [
      {value: '1', label: '一级警情'},
      {value: '2', label: '二级警情'},
      {value: '3', label: '三级警情'},
      {value: '4', label: '四级警情'}
    ],
    // 接警类型
    jjlxdm: [
      {value: '1', label: '110报警'},
      {value: '2', label: '122报警'},
      {value: '3', label: '119报警'},
      {value: '4', label: '综合报警'},
      {value: '9', label: '其他报警'}
    ],
    // 警情类别
    jqlb: [
      {value: '10', label: '刑事案件'},
      {value: '20', label: '治安事件'},
      {value: '30', label: '交通事件'},
      {value: '40', label: '抢险救援'},
      {value: '50', label: '群众求助'},
      {value: '60', label: '社会联动'},
      {value: '70', label: '群体事件'},
      {value: '80', label: '灾害事故'},
      {value: '90', label: '举报线索'},
      {value: '95', label: '投诉监督'},
      {value: '99', label: '其它报警类别'},
      // kunming
      {value: '010000', label: '刑事警情'},
      {value: '020000', label: '治安警情'},
      {value: '030000', label: '交通事故'},
      {value: '040000', label: '火灾事故'},
      {value: '050000', label: '群众求助'},
      {value: '060000', label: '举报线索'},
      {value: '070000', label: '事件'},
      {value: '080000', label: '纠纷'},
      {value: '090000', label: '灾害事故'},
      {value: '100000', label: '其它行政违法'},
      {value: '110000', label: '无效报警'},
      {value: '120000', label: '警务查询'},
      {value: '130000', label: '非正常死亡'},
      {value: '140000', label: '投诉监督'},
      {value: '990000', label: '其他类别'},
      {value: '1191', label: '火灾'},
      {value: '1192', label: '社会救助'},
      {value: '1195', label: '抢险救援'},
      {value: '1193', label: '勤务保卫'},
      {value: '1194', label: '其它'},
      {value: '1221', label: '交通事故'},
      {value: '1222', label: '交通拥堵'},
      {value: '1223', label: '其他'}
    ],
    // 车辆接警处理状态
    carPoliceHandleType: [
      {value: '1', label: '报警或求助'},
      {value: '2', label: '处警反馈'},
      {value: '3', label: '重复报警'},
      {value: '4', label: '工作咨询'},
      {value: '5', label: '骚扰'},
      {value: '6', label: '系统测试'},
      {value: '7', label: '呼入早释或接警员拿起电话之前对方挂掉'},
      {value: '8', label: '其它处理类型'}
    ],
    // 警情状态-车
    jqztForCar: [
      {value: '0', label: '未响应'},
      {value: '1', label: '处理中'},
      {value: '2', label: '完成'},
      {value: '3', label: '取消接警'},
      {value: '4', label: '到场'}
    ],
    // 警情状态
    jqzt: [
      {value: '0', label: '待处理'},
      {value: '1', label: '调派'},
      {value: '2', label: '出警'},
      {value: '3', label: '完成'},
      {value: '4', label: '到场'}
    ],
    // 频道类型
    channelType: [
      {value: '-1', label: '站-站频道'},
      {value: '0', label: '站-所频道'},
      {value: '1', label: '站-队频道'},
      {value: '2', label: 'SOS频道'},
      {value: '3', label: '其他频道'}
    ],

    // 重复方式
    cycle: [
      {value: '1', label: '指定日期'},
      {value: '5', label: '按周重复'}
    ],
    // 重复方式
    repeatWay: [
      {value: '0', label: '按周重复'},
      {value: '1', label: '指定日期'}
    ],
    // 生效日期
    weekdays: [
      {value: '1', label: '星期一'},
      {value: '2', label: '星期二'},
      {value: '3', label: '星期三'},
      {value: '4', label: '星期四'},
      {value: '5', label: '星期五'},
      {value: '6', label: '星期六'},
      {value: '7', label: '星期日'}
    ],
    // 围栏类型
    railtype: [
      {value: '0', label: '圆形'},
      {value: '1', label: '多边形'},
      {value: '2', label: '折线'}
      // {value: '3', label: '道路限制'}
    ],
    // 触发条件
    condition: [
      {value: '1', label: '进入时触发'},
      {value: '2', label: '离开时触发'},
      {value: '3', label: '进入离开均触发'}
    ],
    // 接收报警对象
    reporttype: [
      {value: '0', label: '后视镜'},
      {value: '1', label: '手机号码'}
    ],
    // 菜单资源
    resourcetype: [
      {value: '0', label: '菜单资源'},
      {value: '1', label: '功能资源'}
    ],
    // 视频终端类型
    videoSimType: [
      {value: '0', label: '博实结'},
      {value: '1', label: '宏电'},
      {value: '2', label: '创世'},
      {value: '3', label: '易站通达'}
    ],

    // 用户状态
    userStatus: [
      {value: '0', label: '未激活'},
      {value: '1', label: '激活'}
    ],
    // 预警类型
    alarmtype: [
      {value: '0', label: '离线预警'},
      {value: '1', label: '静止预警'}
    ],
    // 频道类型
    voiceType: [
      {value: '0', label: '频道语音'},
      {value: '1', label: '警情语音'},
      {value: '2', label: '指挥中心语音'}
    ],
    // 视频终端在线状态
    videoDeviceOnlineStatus: [
      {value: '0', label: '离线'},
      {value: '1', label: '在线'}
    ]
  },
  mutations: {},
  actions: {
    init({commit}) {
      commit('getJqlb');
    }
  },
  getters: {
    // 获取整个枚举
    list: (state) => (emunName) => {
      return state[emunName] || [];
    },

    // 获取枚举的某个值组成数组[value,value]
    array: (state) => (emunName, by) => {
      let item = [];
      for (let i in state[emunName]) {
        item.push(state[emunName][i][by]);
      }
      return item;
    },
    // 根据某个名筛选枚举('hpzl', 'value', '02')
    item: (state, getters) => (emunName, by, val) => {
      return getters.fliter(state[emunName], by, val);
    },
    // 根据某个名筛选枚举('hpzl', 'value', '02', 'subvalue', 'sub02')
    childrenItem: (state, getters) => (emunName, by, val, subBy, subVal) => {
      const subitem = getters.fliter(state[emunName], by, val);
      if (subitem.children) {
        return getters.fliter(subitem.children, subBy, subVal);
      }
      return {
        value: null,
        label: null
      };
    },

    // 筛选工具
    fliter: () => (data, label, val) => {
      for (let i in data) {
        if (val && data[i][label] === val.toString()) {
          return data[i];
        }
      }
      return {
        value: null,
        label: null
      };
    }
  }
};

export default enums;
